package com.xr.blog.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xr.blog.dao.SysUserMapper;
import com.xr.blog.pojo.SysUser;
import com.xr.blog.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;


@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
    @Autowired
    SysUserMapper sysUserMapper;
    @Override
    public SysUser findByUserName(String username) {

        return sysUserMapper.selectOne(new QueryWrapper<SysUser>().eq("username",username));
    }

    @Override
    public List<String> findRolesByUserName(String username) {
        return sysUserMapper.findRolesByUserName(username);
    }

    @Override
    public SysUser findUserById(Long userId) {
        SysUser user = sysUserMapper.selectById(userId);
        return user;
    }

    @Override
    public SysUser findUserByUsername(String username) {
        return sysUserMapper.selectOne(new QueryWrapper<SysUser>().eq("username", username));
    }

    @Override
    public SysUser findUserByEmail(String email) {
        return sysUserMapper.selectOne(new QueryWrapper<SysUser>().eq("email", email));
    }
}